﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/People.Master" Inherits="System.Web.Mvc.ViewPage<MedicalManagementSystem.Models.PatientChart>" %>

<%@ Import Namespace="MedicalManagementSystem.Models" %>

<%@ Import Namespace="MedicalManagementSystem.Utils" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Поступление пациента.
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainRightColumn" runat="server">
    <h2>Поступление пациента.</h2>
    <%var getPatientUrl = Url.Action("FindFromPassivePatients", "Patient");%>
    <div class="ui-widget" align="center">
        <% using (Html.BeginForm())
           {%>
        <%=Html.ValidationSummary(false, "Пожалуйста, исправьте ошибки и попробуйте снова.")%>
        <table class="CreatePatientChartTable">
            <tr>
                <td>
                    <fieldset>
                        <label for="patientId">
                            Пациент:</label>
                        <%
               if (Model.Patient != null)
               {%>
                        <%
                   Model.LoadPatient();%>
                        <%=Html.Hidden("patientId", Model.Patient.id)%>
                        <b>
                            <%=Html.Encode(Model.Patient)%></b>
                        <%}
               else
               {%>
                        <%=Html.Hidden("patientId")%>
                        <%=Html.TextBox("PatientList")%>
                        <%=Html.ValidationMessage("patientId", "*")%>
                        <br />
                        <small>(введите инициалы и нажмите "Найти")</small>
                        <br />

                        <%}%>
                        
                        <label for="DateArrive">Дата поступления:</label>
                        <%=Html.TextBox("DateArrive", "")%>
                        <%=Html.ValidationMessage("DateArrive", "*")%>
                        
                        <label for="Forced">Принудительное лечение:</label>
                        <%=Html.CheckBox("Forced")%>
                        <%=Html.ValidationMessage("Forced", "*")%>
                        
                        <label for="doctorId">Лечащий врач</label>
                        <%=Html.DropDownList("doctorId",
                            DbContext.Instance.Doctor.ToList()
                            .OrderBy(d=>d.Initials)
                            .Select(d=>new SelectListItem(){Text = d.Initials, 
                                Value = d.id.ToString()}))%>
                        <br /> <br/>

                        <p>
                            <input type="submit" value="Создать" />
                        </p>
                    </fieldset>
                </td>
                <td>
                    <%if (Model.Patient == null)
                          Html.RenderPartial(Url.Content("../Patient/PatientSearchBox"), new PatientSearchModel(getPatientUrl,
                                                                                                   "patientId", "PatientList", 7));%>
                </td>
            </tr>
        </table>
        <%}%>
    </div>
    <div id="left">
        <a onclick="javascript:goback()">Назад</a>
    </div>
    <script type="text/javascript">
        $(function () {
            $('#DateArrive').datepicker(
                {
                    changeMonth: true,
                    changeYear: true,
                    maxDate: new Date()
                }, $.datepicker.regional["ru"]);
            });
    </script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
